package com.miao.util;

import lombok.Data;

/**
 * @Author <a href="https://gitee.com/a-tom-is-cry">Xing</a>
 * @Date 2024/10/15 14:10
 * @Description
 */
@Data
public class Result<T> {
    private Integer code;
    private T data;
    private String message;

    {
        code = Integer.valueOf(200);
        message = "success";
    }

    public Result<T> success(T data){
        Result<T> objectResult = new Result<>();
        objectResult.data = data;
        return objectResult;
    }

    public Result error(Integer code){
        Result result = new Result<>();
        result.setCode(code);
        return result;
    }

    public Result error(Integer code,String message){
        Result result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

}
